#define _CRT_SECURE_NO_WARNINGS 1


#include<vector>
#include<iostream>

using namespace std;

bool Func(vector<int>& v, int k)
{
	int size = v.size();
	if (size == 1)
	{
		return true;
	}
	int begin = 0, end = 1;
	while (end < size)
	{
		if (abs(v[begin] - v[end]) == k)
		{
			return false;
		}
		begin++;
		end++;
	}
	return true;
}

void BackTrack(vector<vector<int>>& vv, int start, vector<int>& nums, vector<int>& temp, int k)
{
	if (Func(temp, k))
	{
		vv.push_back(temp);
	}
	for (int i = start; i < nums.size(); i++)
	{
		temp.push_back(nums[i]);
		BackTrack(vv, i + 1, nums, temp, k);
		temp.pop_back();
	}
}

int beautifulSubsets(vector<int>& nums, int k)
{
	vector<vector<int>> vv;
	vector<int> temp;
	BackTrack(vv, 0, nums, temp, k);
	return vv.size();
}

int main()
{
	vector<int> v = { 2,4,6 };

	cout << beautifulSubsets(v, 2) << endl;

	return 0;
}